package com.anlu.yue.controller;

import com.anlu.yue.model.ResultData;
import com.anlu.yue.model.ao.GetUserAO;
import com.anlu.yue.model.userinfo.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

@RestController
public class TestController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());


    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/comsumer/payment/get/{id}")
    public ResultData getPayment(@PathVariable("id") Long id){

        String res = "您请求的值是:"+id;
        return ResultData.success(res);
    }

    @GetMapping("/testGet")
    public ResultData testGet(){


        return ResultData.success();
    }

    @GetMapping("/getUserInfo")
    public User getUserInfo(@RequestBody @Validated GetUserAO getUserAO){

        User user = new User();
        user.setUserName(getUserAO.getUserName());
        user.setUid(getUserAO.getId());
        return user;
    }

    @PostMapping("/testGetUserInfo")
    public ResultData<User> testGetUserInfo(@RequestBody @Validated GetUserAO getUserAO){

        User user = new User();
        user.setUserName(getUserAO.getUserName());
        user.setUid(getUserAO.getId());
        return ResultData.success(user);
    }



}
